package Classes.core 
{
	import Box2D.Common.Math.b2Vec2;
	import Box2D.Dynamics.b2DebugDraw;
	import Box2D.Dynamics.b2World;
	import Classes.Main;
	import Classes.Objects.PhysicsObject;
	import flash.display.Sprite;
	/**
	 * ...
	 * @author Seven Game Studio
	 */
	public class World extends b2World
	{
		public var scaleFactor:Number;
		
		public function World(gravity:b2Vec2, doSleep: Boolean, scaleFactor: Number) 
		{
			super(gravity, doSleep);
			this.scaleFactor = scaleFactor;
			debug_draw();
		}
		
		public function debug_draw():void 
		{
			var debug_draw:b2DebugDraw = new b2DebugDraw();
			var debug_sprite:Sprite = new Sprite();
			Main.getInstance().MC_tela.addChild(debug_sprite);
			debug_draw.SetSprite(debug_sprite);
			debug_draw.SetDrawScale(scaleFactor);
			debug_draw.SetFlags(b2DebugDraw.e_shapeBit);
			debug_draw.SetAlpha(0.5);
			SetDebugDraw(debug_draw);
		}
		
		public function createLevel(objectList:Array)
		{
			for (var i: int = 0; i < objectList.length; i++)
			{
				var objeto : PhysicsObject = new PhysicsObject(this, objectList[i]["isStatic"], objectList[i]["x"], objectList[i]["y"], objectList[i]["width"], objectList[i]["height"], objectList[i]["artName"], objectList[i]["rotation"]); 
			}
		}
		
	}

}